package com.hxx.day1.controller;

import com.hxx.day1.domain.Person;

import java.util.Scanner;

public class PersonAction {
    public static void main(String[] args) {
        PersonController per = new PersonController();
        Scanner scanner = new Scanner(System.in);
        boolean flag = true;
        int key = 0;
        do{
            System.out.println("1表示添加;2表示删除;3表示更新;4表示查找;5显示");
            key = scanner.nextInt();
            switch (key){
               case 1:
                   Person person = new Person();
                   System.out.println("请输入数字id");
                   person.setId(scanner.nextInt());
                   System.out.println("请输入姓名");
                   person.setUserName(scanner.next());
                   System.out.println("请输入性别");
                   person.setSex(scanner.next());
                   System.out.println("请输入年龄");
                   person.setAge(scanner.nextInt());
                   //调用保存方法
                   per.save(person);
                   break;
               case 2:
                   System.out.println("请输入一个需要删除的数字");
                   Person person1 = new Person();
                   person1.setId(scanner.nextInt());
                   per.delete(person1);
                   break;
               case 3:
                   Person person2 = new Person();
                   System.out.println("请输入更新id");
                   person2.setId(scanner.nextInt());
                   System.out.println("请输入新姓名");
                   person2.setUserName(scanner.next());
                   System.out.println("请输入新性别");
                   person2.setSex(scanner.next());
                   System.out.println("请输入新年龄");
                   person2.setAge(scanner.nextInt());
                   per.update(person2);
                   break;
               case 4:

                   break;
               case 5:
                  per.findAll();
                  break;
               default:
                   flag = false;
                   break;
           }
        }while (flag);
    }
}
